const fs = require('fs/promises')
const useRouter = async app => {
  const files = await fs.readdir('src/router')
  files.forEach(file => {
    if (file === 'index.js') return 
    const router = require('../router/' + file)
    app.use(router.routes())
    app.use(router.allowedMethods()) 
  })
}

module.exports = useRouter